﻿Imports MetodosComuns
Imports extranet.BC
Imports extranet.BE

Partial Class Eventos_AdmEvtListaEventos
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        '==================       PROCEDIMENTO  PADRÃO  SEGURANÇA     =============================
        Dim objBESeguranca As BESeguranca
        Dim objBEUsuario As BEUsuario = Session("objBEUsuario")
        If IsNothing(objBEUsuario) Then Response.Redirect(TELA_LOGOUT)
        Session("strTela") = MetodosComuns.GetCurrentPageName()
        If Not IsPostBack Then          ' SEGURANÇA
            objBESeguranca = BCSeguranca.SelecionaPermissoes(objBEUsuario.GrupoAcesso, Session("strTela"))
            If Not objBESeguranca.Autorizado Then Response.Redirect(TELA_LOGOUT)
            Session("objBESeguranca") = objBESeguranca
        Else
            objBESeguranca = Session("objBESeguranca")
        End If

        If Not IsPostBack Then
            grvEventos.DataSource = BCEvento.ListarEvento(True)
            grvEventos.DataBind()
        End If
    End Sub

    Protected Sub btnNovoEvento_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNovoEvento.Click
        Response.Redirect("AdmEvtGerenciamentoEvento.aspx")
    End Sub

    Protected Sub grvEventos_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grvEventos.RowEditing
        Response.Redirect("AdmEvtGerenciamentoEvento.aspx?Evento=" & grvEventos.DataKeys(e.NewEditIndex).Value.ToString())
    End Sub

    Protected Sub grvEventos_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles grvEventos.RowDeleting
        Response.Redirect("AdmEvtGerenciamentoInscrito.aspx?Evento=" & grvEventos.DataKeys(e.RowIndex).Value.ToString())
    End Sub

    Protected Sub rblStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rblStatus.SelectedIndexChanged
        Select Case rblStatus.SelectedValue
            Case "Ativos"
                grvEventos.DataSource = BCEvento.ListarEvento(True)
            Case "Todos"
                grvEventos.DataSource = BCEvento.ListarEvento(False)
        End Select
        grvEventos.DataBind()
    End Sub
End Class
